package com.bgs.engineering.common.errorCode;

import lombok.ToString;

/**
 * @auther zcy
 * @date 2019/10/11 10:40
 */
@ToString
public enum EmErrorCode implements CommonError {

    //通用的错误类型10001
    PARAMETER_VALIDATION_ERROR(100001, "参数不合法"), //未知错误
    UNKNOW_ERROR(100002, "未知错误"),
    //新增失败
    SAVE_ERROR(100003, "新增失败"),
    //删除失败
    DELETE_ERROR(100004, "删除失败"),
    //修改失败
    UPDATE_ERROR(100005, "修改失败"),
    //新增失败
    SAVE_OK(100006, "新增成功"),
    //删除失败
    DELETE_OK(100007, "删除成功"),
    //修改失败
    UPDATE_OK(100008, "修改成功"),
    ID_NULL(100009, "id不能为空和0"),
    OBJECT_NOT_NULL(100022, "id不能为空和0"),
    ID_NOT_OBJECT(100023, "没有此查询结果"),
    PROJECT_NAME_ISNULL(100010, "项目名称不能为空"),
    OBJECT_ISNULL(100011, "id不存在，无法删除，请输入正确id进行删除"),
    //20000开头为用户信息相关错误信息
    USER_NOT_EXIST(20001, "用户不存在"),
    USER_LOGIN_FAIL(20002, "用户手机号不存在或密码不正确"),
    USER_NOT_LOGIN(20003, "用户还未登录"),
    USER_NOT_EXPIRE(20004, "登录超时,请重新登录！"),
    USER_NOT_AUTH(20005, "用户无权访问！"),
    USER_PASSWORD_ERROR(20006,"用户名或密码错误"),

  USER_OTHER_ERROR(20007, "未知错误"),
  LOGIN_TIMEOUT(20008, "登录超时"),
  USER_ACCOUNT_LOGIN_BY_OTHERS(20009, "账号再其他平台登录"),
  LOGIN_OUT(20010, "登出成功"),
  TOKEN_EXPIRE(20011, "token过期或者无效请重新登录"),
  TOKEN_INVALID(20012, "token无效"),
  CODE_IS_NULL(20013, "验证码不能为空"),
  CODE_IS_ERROR(20014, "验证码错误或者过期"),
  EMAIL_IS_NULL(20015, "邮箱不能为空"),
  PHONE_IS_NULL(20016, "手机号不能为空"),
  USERNAME_IS_NULL(20017, "登录名不能为空"),
  PASSWORD_IS_NULL(20018, "密码不能为空"),

  //30000开头为用户信息相关错误信息
  FILE_EMPTY(30001, "附件不能为空"),
  IMAGE_SIZE_ERROR(30002, "图片过大!"),
  FILE_SIZE_ERROR(30003, "附件过大!"),
  FILE_TYPE_ERROR(30004, "暂不支持此附件类型"),
  FILE_UPLOAD_OK(30005, "附件上传成功"),
  FILE_UPLOAD_ERROR(30006, "附件上传失败"),

  //建表错误
  TABLE_SQL_EMPTY(50001, "后台建表失败，检查设备类型是否正确!"), TABLE_DEVICEtYPE_EMPTY(50002, "设备选择类型不能为空!"),


  //feign 调用接口失败返回异常
  FEIGN_ERROR(70001, "调用远程服务失败"),
  ;

  EmErrorCode(int errCode, String errMsg) {
    this.errCode = errCode;
    this.errMsg = errMsg;
  }

  private int errCode;
  private String errMsg;

  @Override
  public int getErrCode() {
    return this.errCode;
  }

  @Override
  public String getErrMsg() {
    return this.errMsg;
  }

  @Override
  public CommonError setErrorMsg(String errMsg) {
    this.errMsg = errMsg;
    return this;
  }
}
